Skip to content

Always perform a require prior to analyzing a ns #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2021
Merged

Conversation

vemv
Copy link
Member

@vemv vemv commented Jul 9, 2021

Part of #245

Performing this require makes it more likely that t.ana will succeed. I believe it's becase require will also require other stuff recursively. t.ana does so in theory as well but it's a bit more rigid.

[refactor-nrepl.analyzer :as sut]
[clojure.test :refer [deftest is]]))

(deftest ns-ast-test
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that if we comment out this PR's main change, this test would fail, complaining about go-loop

Copy link
Member

@expez expez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man, you are on a tear 🥇

Great job!

@@ -77,7 +77,8 @@
(not (util/self-referential? ns)))
;; Use `locking`, because AST analysis can perform arbitrary evaluation.
;; Parallel analysis is not safe, especially as it can perform `require` calls.
(locking core/require-lock
(locking core/require-lock ;; for both `require` and `aj/analyze-ns`
(require ns) ;; ease the work for t.ana
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a general tip with regards to writing comments: have them answer why questions.

Since it's here we can assume that it's needed, but we're still left asking why that is. You could remedy that with a comment like: ;; t.ana sometimes fails to require the needed namespaces on its own

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use this as the comment here:

Performing this require makes it more likely that t.ana will succeed. I believe it's becase require will also require other stuff recursively. t.ana does so in theory as well but it's a bit more rigid.

@vemv vemv force-pushed the 245--core-async branch from 770c692 to ae064f1 Compare July 9, 2021 13:41
@vemv
Copy link
Member Author

vemv commented Jul 9, 2021

Thanks for the suggestions!

@vemv vemv merged commit c05e692 into master Jul 9, 2021
@vemv vemv deleted the 245--core-async branch July 9, 2021 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants